About the dataset

https://www.kaggle.com/datasets/nathansmallcalder/lol-match-history-and-summoner-data-80k-matches

Read csv files

'
championTbl <- read_tbl("ChampionTbl")
itemTbl<- read_tbl("ItemTbl")
matchStatsTbl <- read_tbl("MatchStatsTbl")
matchTbl <- read_tbl("MatchTbl")
RankTbl <- read_tbl("RankTbl")
SummonerMatchTbl <- read_tbl("SummonerMatchTbl")
TeamMatchTbl <- read_tbl("TeamMatchTbl")
'
## [1] "\nchampionTbl <- read_tbl(\"ChampionTbl\")\nitemTbl<- read_tbl(\"ItemTbl\")\nmatchStatsTbl <- read_tbl(\"MatchStatsTbl\")\nmatchTbl <- read_tbl(\"MatchTbl\")\nRankTbl <- read_tbl(\"RankTbl\")\nSummonerMatchTbl <- read_tbl(\"SummonerMatchTbl\")\nTeamMatchTbl <- read_tbl(\"TeamMatchTbl\")\n"

View datasets

head(championTbl) %>% knitr::kable()
ChampionId ChampionName
0 No Champion
1 Annie
2 Olaf
3 Galio
4 TwistedFate
5 XinZhao
head(itemTbl) %>% knitr::kable()
ItemID ItemName
1001 Boots
1004 Faerie Charm
1006 Rejuvenation Bead
1011 Giant’s Belt
1018 Cloak of Agility
1026 Blasting Wand
head(matchStatsTbl) %>% knitr::kable()
MatchStatsId SummonerMatchFk MinionsKilled DmgDealt DmgTaken TurretDmgDealt TotalGold Lane Win item1 item2 item3 item4 item5 item6 kills deaths assists PrimaryKeyStone PrimarySlot1 PrimarySlot2 PrimarySlot3 SecondarySlot1 SecondarySlot2 SummonerSpell1 SummonerSpell2 CurrentMasteryPoints EnemyChampionFk DragonKills BaronKills visionScore
1 1 30 4765 12541 0 7058 BOTTOM 0 3870 2055 3107 3171 6620 2022 0 2 12 8465 8463 8473 8453 8345 8347 4 7 902 51 0 0 67
2 2 29 8821 14534 1 9618 BOTTOM 0 3870 2065 3107 3158 6620 3916 2 5 23 8465 8463 8473 8453 8345 8347 4 7 902 236 0 0 88
3 3 34 6410 19011 3 9877 BOTTOM 1 3870 3107 1011 3171 6617 3916 0 5 22 8214 8226 8210 8237 8345 8347 4 7 16 498 0 0 97
4 4 51 22206 14771 3 12374 NONE 1 6655 3089 4645 3020 0 0 8 4 35 8112 8143 8140 8106 8226 8210 4 14 103 54 0 0 0
5 5 0 39106 33572 0 15012 TOP 1 4015 223157 226653 222503 223089 447108 13 8 2 0 0 0 0 0 0 2202 2201 800 12 0 0 0
6 6 0 30259 21355 0 12000 TOP 1 223112 223157 447108 223020 223089 444644 6 6 4 0 0 0 0 0 0 2202 2201 127 516 0 0 0
head(matchTbl) %>% knitr::kable()
MatchId Patch QueueType RankFk GameDuration
EUW1_6681382047 13.22.541.9804 CLASSIC 0 1050
EUW1_6681412019 13.22.541.9804 CLASSIC 0 778
EUW1_6681445530 13.22.541.9804 ARAM 0 753
EUW1_6681464371 13.22.541.9804 ARAM 0 853
EUW1_6681718380 13.22.541.9804 ARAM 0 1226
EUW1_6688366852 13.23.544.5515 ARAM 0 1001
head(RankTbl, n = 11) %>% knitr::kable()
RankId RankName
0 Unranked
1 Iron
2 Bronze
3 Silver
4 Gold
5 Platinum
6 Emerald
7 Diamond
8 Master
9 Grandmaster
10 Challenger
head(SummonerMatchTbl) %>% knitr::kable()
SummonerMatchId SummonerFk MatchFk ChampionFk
1 1 EUW1_7565751492 902
2 1 EUW1_7565549583 902
3 1 EUW1_7564803077 16
4 1 EUW1_7564368646 103
5 1 EUW1_7564332041 800
6 1 EUW1_7564297394 127
head(TeamMatchTbl) %>% knitr::kable()
TeamID MatchFk B1Champ B2Champ B3Champ B4Champ B5Champ R1Champ R2Champ R3Champ R4Champ R5Champ BlueBaronKills BlueRiftHeraldKills BlueDragonKills BlueTowerKills BlueKills RedBaronKills RedRiftHeraldKills RedDragonKills RedTowerKills RedKills RedWin BlueWin
1 EUW1_7565751492 897 154 157 51 902 164 5 25 221 497 0 1 1 3 13 1 0 3 8 26 1 0
2 EUW1_7565549583 82 238 157 236 89 6 254 127 42 902 1 0 3 10 39 0 1 1 3 33 0 1
3 EUW1_7564803077 516 28 4 498 235 23 64 38 901 16 0 1 2 7 27 2 0 3 8 37 1 0
4 EUW1_7564368646 54 34 59 498 103 61 25 55 106 5 0 0 0 4 55 0 0 0 0 39 0 1
5 EUW1_7564332041 12 800 111 150 142 141 101 55 950 4 0 0 0 0 42 0 0 0 0 0 0 1
6 EUW1_7564297394 45 62 516 897 555 516 80 105 30 161 0 0 0 0 59 0 0 0 0 0 0 1

Champion Table -VA

The following the data set has basically an NA value named ‘No champion’. The data set has been updated so that it only represents actual champions that are playable in League of Legends.

championTbl <- championTbl %>% 
  filter(ChampionId > 0)
head(championTbl)
## # A tibble: 6 × 2
##   ChampionId ChampionName
##        <dbl> <chr>       
## 1          1 Annie       
## 2          2 Olaf        
## 3          3 Galio       
## 4          4 TwistedFate 
## 5          5 XinZhao     
## 6          6 Urgot

As you can see, there is no longer a champion ID 0 - No champion. Using the dplyr function filter we successfully removed any irrelevant or not needed rows.

MSI Table -TY

Creating a new table called ‘MSI_Tbl’ to join the Match Stats table and Item Table

ooo;’

match_rank Table -VA

We have created a new table called match_rank_tbl. The purpose of this table is to join both the match table and the rank table by their RankFk == RankId. This will let us know whether the match was ranked or unranked.

'match_rank_tbl <- full_join(matchTbl,RankTbl,join_by(RankFk == RankId))'
## [1] "match_rank_tbl <- full_join(matchTbl,RankTbl,join_by(RankFk == RankId))"
head(match_rank_tbl)
## # A tibble: 6 × 6
##   MatchId         Patch          QueueType RankFk GameDuration RankName
##   <chr>           <chr>          <chr>      <dbl>        <dbl> <chr>   
## 1 EUW1_6681382047 13.22.541.9804 CLASSIC        0         1050 Unranked
## 2 EUW1_6681412019 13.22.541.9804 CLASSIC        0          778 Unranked
## 3 EUW1_6681445530 13.22.541.9804 ARAM           0          753 Unranked
## 4 EUW1_6681464371 13.22.541.9804 ARAM           0          853 Unranked
## 5 EUW1_6681718380 13.22.541.9804 ARAM           0         1226 Unranked
## 6 EUW1_6688366852 13.23.544.5515 ARAM           0         1001 Unranked

TMR Tbl -TY

Create new table called ‘TMM_Tbl’ to join Team Match Table and Match Table

'TMR_Tble <- full_join(TeamMatchTbl, match_rank_tbl, by = join_by(MatchFk == MatchId))'
## [1] "TMR_Tble <- full_join(TeamMatchTbl, match_rank_tbl, by = join_by(MatchFk == MatchId))"
TMR_Tble
## # A tibble: 29,261 × 30
##    TeamID MatchFk        B1Champ B2Champ B3Champ B4Champ B5Champ R1Champ R2Champ
##     <dbl> <chr>            <dbl>   <dbl>   <dbl>   <dbl>   <dbl>   <dbl>   <dbl>
##  1      1 EUW1_75657514…     897     154     157      51     902     164       5
##  2      2 EUW1_75655495…      82     238     157     236      89       6     254
##  3      3 EUW1_75648030…     516      28       4     498     235      23      64
##  4      4 EUW1_75643686…      54      34      59     498     103      61      25
##  5      7 EUW1_75642579…      86     245      25     523     888      10      64
##  6      8 EUW1_75636855…      69      11     150      81     201     133     245
##  7      9 EUW1_75636056…      17     102      38      15     902     516     517
##  8     10 EUW1_75635534…      29     517      38     804      22      84     895
##  9     11 EUW1_75633454…      90      61     516     235     875     267     202
## 10     12 EUW1_75632974…     887      18      99      64      41     102     238
## # ℹ 29,251 more rows
## # ℹ 21 more variables: R3Champ <dbl>, R4Champ <dbl>, R5Champ <dbl>,
## #   BlueBaronKills <dbl>, BlueRiftHeraldKills <dbl>, BlueDragonKills <dbl>,
## #   BlueTowerKills <dbl>, BlueKills <dbl>, RedBaronKills <dbl>,
## #   RedRiftHeraldKills <dbl>, RedDragonKills <dbl>, RedTowerKills <dbl>,
## #   RedKills <dbl>, RedWin <dbl>, BlueWin <dbl>, Patch <chr>, QueueType <chr>,
## #   RankFk <dbl>, GameDuration <dbl>, RankName <chr>, Winning_Team <chr>

SMR tbl -VA

The following table was created in order to join both the summoner match table and a match rank table. This table displays a smaller depiction

'SMR_Tbl <- full_join(SummonerMatchTbl, championTbl, join_by(ChampionFk == ChampionId))

SMR_Tbl <- full_join(SMR_Tbl, match_rank_tbl, by = join_by(MatchFk == MatchId))'
## [1] "SMR_Tbl <- full_join(SummonerMatchTbl, championTbl, join_by(ChampionFk == ChampionId))\n\nSMR_Tbl <- full_join(SMR_Tbl, match_rank_tbl, by = join_by(MatchFk == MatchId))"
head(SMR_Tbl)
## # A tibble: 6 × 10
##   SummonerMatchId SummonerFk MatchFk     ChampionFk ChampionName Patch QueueType
##             <dbl>      <dbl> <chr>            <dbl> <chr>        <chr> <chr>    
## 1               1          1 EUW1_75657…        902 Milio        15.2… CLASSIC  
## 2               2          1 EUW1_75655…        902 Milio        15.2… CLASSIC  
## 3               3          1 EUW1_75648…         16 Soraka       15.2… CLASSIC  
## 4               4          1 EUW1_75643…        103 Ahri         15.2… ARAM     
## 5               5          1 EUW1_75643…        800 Mel          15.2… CHERRY   
## 6               6          1 EUW1_75642…        127 Lissandra    15.2… CHERRY   
## # ℹ 3 more variables: RankFk <dbl>, GameDuration <dbl>, RankName <chr>

Joining SMR table and MSI table -TY

#SMRI_tbl <- full_join(SMR_Tbl, MSI_Tbl, by = join_by(SummonerMatchId==SummonerMatchFk))
#SMRI_tbl 
#Needs further filtering 

Tamana MSI_tbl and Match_rank_tbl dplyr and plot functions

#MSI_Tbl

  1. How many SummonerMatchFk play more than one lane
MSI_Tbl %>%
  group_by(SummonerMatchFk)%>%
  summarise(num_lanes = n_distinct(Lane))%>% #count the unique lanes
  filter(num_lanes > 1)%>%
  summarise(total_players = n())
## # A tibble: 1 × 1
##   total_players
##           <int>
## 1          6279
  1. Find the Mean, Median, Max, and Min for the following:

Mean median min and max of minions kiled:

## # A tibble: 1 × 4
##   avg_minionsKilled median_minionsKilled min_minionsKilled max_minionsKilled
##               <dbl>                <dbl>             <dbl>             <dbl>
## 1              104.                   79                 0               501
# mean, median, min, and max of TurretDmg
MSI_Tbl%>%
  summarise(avg_TurretDmgDealt = mean(TurretDmgDealt, na.rm = T),
            median_TurretDmgDealt = median(TurretDmgDealt, na.rm = T),
            min_TurretDmgDealt = min(TurretDmgDealt, na.rm = T), 
            max_TurretDmgDealt = max(TurretDmgDealt, na.rm = T))
## # A tibble: 1 × 4
##   avg_TurretDmgDealt median_TurretDmgDealt min_TurretDmgDealt max_TurretDmgDealt
##                <dbl>                 <dbl>              <dbl>              <dbl>
## 1               1.71                     1                  0                 12
# mean, median, min, and max of DmgTaken
MSI_Tbl%>%
  summarise(avg_DmgTaken = mean(DmgTaken, na.rm = T),
            median_DmgTaken = median(DmgTaken, na.rm = T), 
            min_DmgTaken = min(DmgTaken, na.rm = T),
            max_DmgTaken = max(DmgTaken, na.rm = T))
## # A tibble: 1 × 4
##   avg_DmgTaken median_DmgTaken min_DmgTaken max_DmgTaken
##          <dbl>           <dbl>        <dbl>        <dbl>
## 1       30430.           26852            0       435808
# mean, median, min, and max of DmgDealt
MSI_Tbl%>%
  summarise(avg_DmgDealt = mean(DmgDealt, na.rm = T),
            median_DmgDealt = median(DmgDealt, na.rm = T), 
            min_DmgDealt = min(DmgDealt, na.rm = T),
            max_DmgDealt = max(DmgDealt, na.rm = T))
## # A tibble: 1 × 4
##   avg_DmgDealt median_DmgDealt min_DmgDealt max_DmgDealt
##          <dbl>           <dbl>        <dbl>        <dbl>
## 1       26312.           22424            0       314904
# mean, median, min, and max of totalGold
MSI_Tbl%>%
  summarise(avg_TotalGold = mean(TotalGold, na.rm = T),
            median_TotalGold = median(TotalGold, na.rm = T), 
            min_TotalGold = min(TotalGold, na.rm = T),
            max_TotalGold = max(TotalGold, na.rm = T))
## # A tibble: 1 × 4
##   avg_TotalGold median_TotalGold min_TotalGold max_TotalGold
##           <dbl>            <dbl>         <dbl>         <dbl>
## 1        12351.            11969           500         48226
  1. Create new column (boolean) for indicating win or lose. Filter to win and lose only and create a ggplots.
MSI_Tbl%>%
  mutate(won = Win != 0)%>%
  drop_na(won)%>% 
  ggplot(aes(x=won, fill=won)) + 
  geom_bar() +
  labs(title = "Win vs. Lose",
       x = "results",
       y = "count")

  1. MSI_tbl (ask professor) Items, filter remove NAs, count total items, most popular items, least popular items. Median qne mean items a player holds.
#Lost and confused about this part, will have to ask the professor 
MSI_Tbl%>%
  drop_na(item1, item2, item3, item4, item5, item6)
## # A tibble: 78,863 × 37
##    MatchStatsId SummonerMatchFk MinionsKilled DmgDealt DmgTaken TurretDmgDealt
##           <dbl>           <dbl>         <dbl>    <dbl>    <dbl>          <dbl>
##  1            1               1            30     4765    12541              0
##  2            2               2            29     8821    14534              1
##  3            3               3            34     6410    19011              3
##  4            4               4            51    22206    14771              3
##  5            5               5             0    39106    33572              0
##  6            6               6             0    30259    21355              0
##  7            7               7            28     3775    12061              0
##  8            8               8            36     4217    13464              0
##  9            9               9            31    10255    19432              1
## 10           10              10            42    51900    32851              2
## # ℹ 78,853 more rows
## # ℹ 31 more variables: TotalGold <dbl>, Lane <chr>, Win <dbl>, item1 <dbl>,
## #   item2 <dbl>, item3 <dbl>, item4 <dbl>, item5 <dbl>, item6 <dbl>,
## #   kills <dbl>, deaths <dbl>, assists <dbl>, PrimaryKeyStone <dbl>,
## #   PrimarySlot1 <dbl>, PrimarySlot2 <dbl>, PrimarySlot3 <dbl>,
## #   SecondarySlot1 <dbl>, SecondarySlot2 <dbl>, SummonerSpell1 <dbl>,
## #   SummonerSpell2 <dbl>, CurrentMasteryPoints <dbl>, EnemyChampionFk <dbl>, …
  1. Line plot game duration as the Y value and Queue type as the X value, filter based on RankName.
match_rank_tbl %>%
  group_by(RankName)%>%
  summarise(Duration= n())
## # A tibble: 11 × 2
##    RankName    Duration
##    <chr>          <int>
##  1 Bronze           784
##  2 Challenger       223
##  3 Diamond         2636
##  4 Emerald         4551
##  5 Gold            2697
##  6 Grandmaster      956
##  7 Iron             182
##  8 Master         13688
##  9 Platinum        4014
## 10 Silver          1552
## 11 Unranked        4138
ggplot(match_rank_tbl, aes(color= QueueType,x = GameDuration)) + 
  geom_density() + 
  labs(title = "Game Duration",
  x = "Queue Type",
  y = "Time")

  1. Plot game duration density
ggplot(match_rank_tbl, aes(x=GameDuration, fill = QueueType)) +
  geom_density() +
  labs(title = "Game Duration") + 
  facet_wrap(~QueueType)

#p <- full_join(SummonerMatchTbl, MSI_Tbl, by = join_by(SummonerMatchFK == SummonerMatchId))
#p

Veronica

  1. TMR_tbl create column (boolean) indicating who won.
head(TMR_Tble)
## # A tibble: 6 × 30
##   TeamID MatchFk B1Champ B2Champ B3Champ B4Champ B5Champ R1Champ R2Champ R3Champ
##    <dbl> <chr>     <dbl>   <dbl>   <dbl>   <dbl>   <dbl>   <dbl>   <dbl>   <dbl>
## 1      1 EUW1_7…     897     154     157      51     902     164       5      25
## 2      2 EUW1_7…      82     238     157     236      89       6     254     127
## 3      3 EUW1_7…     516      28       4     498     235      23      64      38
## 4      4 EUW1_7…      54      34      59     498     103      61      25      55
## 5      7 EUW1_7…      86     245      25     523     888      10      64       3
## 6      8 EUW1_7…      69      11     150      81     201     133     245     101
## # ℹ 20 more variables: R4Champ <dbl>, R5Champ <dbl>, BlueBaronKills <dbl>,
## #   BlueRiftHeraldKills <dbl>, BlueDragonKills <dbl>, BlueTowerKills <dbl>,
## #   BlueKills <dbl>, RedBaronKills <dbl>, RedRiftHeraldKills <dbl>,
## #   RedDragonKills <dbl>, RedTowerKills <dbl>, RedKills <dbl>, RedWin <dbl>,
## #   BlueWin <dbl>, Patch <chr>, QueueType <chr>, RankFk <dbl>,
## #   GameDuration <dbl>, RankName <chr>, Winning_Team <chr>
  1. TMR_tbl Filter teams with winning arams, classics based on rank. Bar graph & scatter plot x = rank, y = # of wins, color by queue types, density. face wrap

Let us look at all winning teams from each map type.

source(here::here("WinningTeams","app.R"))
shinyApp(ui, server) 
Shiny applications not supported in static R Markdown documents
head(Team_Winner_Tbl, n = 10) 
## # A tibble: 10 × 11
##    TeamID MatchFk         Side  GameDuration QueueType RankName Kills BaronKills
##     <dbl> <chr>           <chr>        <dbl> <chr>     <chr>    <dbl>      <dbl>
##  1      1 EUW1_7565751492 Red           1751 CLASSIC   Diamond     26          1
##  2      2 EUW1_7565549583 Blue          2092 CLASSIC   Diamond     39          1
##  3      3 EUW1_7564803077 Red           2332 CLASSIC   Diamond     37          2
##  4      4 EUW1_7564368646 Blue           984 ARAM      Diamond     55          0
##  5      7 EUW1_7564257986 Blue          1676 CLASSIC   Diamond     24          1
##  6      8 EUW1_7563685543 Blue          1749 CLASSIC   Diamond     34          1
##  7      9 EUW1_7563605642 Blue          2313 CLASSIC   Diamond     45          2
##  8     10 EUW1_7563553417 Red           1401 ARAM      Diamond     91          0
##  9     11 EUW1_7563345484 Red           1145 ARAM      Diamond     64          0
## 10     12 EUW1_7563297438 Blue          1525 ARAM      Diamond     72          0
## # ℹ 3 more variables: RiftHeraldKills <dbl>, DragonKills <dbl>,
## #   TowerKills <dbl>
  1. TMR_tbl Filter winning teams, most used champion in red team and blue team

  2. TMR_tbl find the mean, median, max and min (all kills) only for classic queue types

TMR_Tble %>%
  filter(QueueType == "CLASSIC") %>% 
  summarise(
    Total_Mean_Kills = mean(RedKills + BlueKills, na.rm = TRUE),
    Total_Medium_Kills = median(RedKills + BlueKills, na.rm = TRUE),
    Max_Kills = max(RedKills + BlueKills, na.rm = TRUE),
    Red_Mean = mean(RedKills, na.rm = TRUE),
    Blue_Mean = mean(BlueKills, na.rm = TRUE),
    Red_Median = median(RedKills, na.rm = TRUE),
    Blue_Median = median(BlueKills, na.rm = TRUE),
    Red_Max = max(RedKills, na.rm = TRUE),
    Blue_Min = max(BlueKills, na.rm = TRUE)
    )
## # A tibble: 1 × 9
##   Total_Mean_Kills Total_Medium_Kills Max_Kills Red_Mean Blue_Mean Red_Median
##              <dbl>              <dbl>     <dbl>    <dbl>     <dbl>      <dbl>
## 1             58.2                 58       169     28.9      29.3         29
## # ℹ 3 more variables: Blue_Median <dbl>, Red_Max <dbl>, Blue_Min <dbl>
  1. TMR_tbl Count the number game plays per queue types plot
ggplotly( ggplot(TMR_Tble,aes(x = QueueType, fill = QueueType, text = paste("Count:", after_stat(count)))) + geom_bar(), tooltip = "text")
  1. SMR_tbl: Top 10 people that play: Queue types. - instead found each player and the amount of games they play per queue type
Player_Games <- SMR_Tbl %>% 
  select(SummonerFk,QueueType,RankFk,RankName) %>% 
  group_by(QueueType, SummonerFk, RankName) %>%
  summarise(games = n()) %>% 
  arrange(SummonerFk)
## `summarise()` has grouped output by 'QueueType', 'SummonerFk'. You can override
## using the `.groups` argument.
ggplotly(ggplot(Player_Games,aes(x = QueueType, fill = QueueType, text = paste("Count:", after_stat(count)))) + geom_bar(), tooltip = "text", na.rm = TRUE)
#ggplotly(ggplot(Player_Games,aes(x = QueueType, y = RankName, color = QueueType) + geom_bar(), tooltip = "text", na.rm = TRUE)


8. SMR_tbl:  Histogram champions


``` r
#CHANGE
  1. SMR_tbl: Filter MSI_table to only have matchID and wins. Join with SMR table. Calculate the top 10 players with the most wins.